<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Backupmanager
 *
 * @author maxi
 */
class BackupManager {

    public function realizarBackup() {

        $db_server=sfConfig::get('app_db_server');
        $db_username=sfConfig::get('app_db_username');
        $db_password=sfConfig::get('app_db_password');
        $db_newlink="";
        $db_name=sfConfig::get('app_db_name');
        $db_save_dir=sfConfig::get('app_db_dir');

        if ($db_resource = mysql_connect($db_server, $db_username, $db_password)) {
            if (mysql_select_db($db_name, $db_resource)) {
                $backupFile = $db_name . "_" . date("Y-m-d-H-i-s") . ".tar.gz";
                $command = "mysqldump --opt 
                    -h " . $db_server .
                " -u " . $db_username .
                " -p " . $db_password .
                " " . $db_name . " | gzip > "
                . $db_save_dir . "/" . $backupFile;
                
                system($command);
            }
        }

        mysql_close($db_resource);
    }

}

?>
